package com._520it.crm.service.impl;

import com._520it.crm.domain.DriverInfo;
import com._520it.crm.mapper.DriverInfoMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.QueryObject;
import com._520it.crm.service.IDriverInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created by 呆 on 2017/10/3.
 */
@Service
public class DriverInfoServiceImpl implements IDriverInfoService {
    @Autowired
    private DriverInfoMapper driverInfoMapper;
    @Override
    public int deleteByPrimaryKey(Long id) {
        return driverInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(DriverInfo driverInfo) {
        return driverInfoMapper.insert(driverInfo);
    }

    @Override
    public DriverInfo selectByPrimaryKey(Long id) {
        return driverInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<DriverInfo> selectAll() {
        return driverInfoMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(DriverInfo driverInfo) {
        return driverInfoMapper.updateByPrimaryKey(driverInfo);
    }

    @Override
    public PageResult query(QueryObject qo) {
        Integer totalCount = driverInfoMapper.queryforCount(qo);
        if (totalCount==0){
            return new PageResult(0, Collections.EMPTY_LIST);
        }
        List<DriverInfo> data = driverInfoMapper.queryforList(qo);
        return new PageResult(totalCount,data);
    }


}
